/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
using System;
using System.Collections.Generic;

using Aliyun.Acs.Core.Transform;
using Aliyun.Acs.Slb.Model.V20130221;

namespace Aliyun.Acs.Slb.Transform.V20130221
{
    public class DescribeBackendServersResponseUnmarshaller
    {
        public static DescribeBackendServersResponse Unmarshall(UnmarshallerContext _ctx)
        {
			DescribeBackendServersResponse describeBackendServersResponse = new DescribeBackendServersResponse();

			describeBackendServersResponse.HttpResponse = _ctx.HttpResponse;
			describeBackendServersResponse.RequestId = _ctx.StringValue("DescribeBackendServers.RequestId");

			List<DescribeBackendServersResponse.DescribeBackendServers_Listener> describeBackendServersResponse_listeners = new List<DescribeBackendServersResponse.DescribeBackendServers_Listener>();
			for (int i = 0; i < _ctx.Length("DescribeBackendServers.Listeners.Length"); i++) {
				DescribeBackendServersResponse.DescribeBackendServers_Listener listener = new DescribeBackendServersResponse.DescribeBackendServers_Listener();
				listener.ListenerPort = _ctx.IntegerValue("DescribeBackendServers.Listeners["+ i +"].ListenerPort");

				List<DescribeBackendServersResponse.DescribeBackendServers_Listener.DescribeBackendServers_BackendServer> listener_backendServers = new List<DescribeBackendServersResponse.DescribeBackendServers_Listener.DescribeBackendServers_BackendServer>();
				for (int j = 0; j < _ctx.Length("DescribeBackendServers.Listeners["+ i +"].BackendServers.Length"); j++) {
					DescribeBackendServersResponse.DescribeBackendServers_Listener.DescribeBackendServers_BackendServer backendServer = new DescribeBackendServersResponse.DescribeBackendServers_Listener.DescribeBackendServers_BackendServer();
					backendServer.ServerHealthStatus = _ctx.StringValue("DescribeBackendServers.Listeners["+ i +"].BackendServers["+ j +"].ServerHealthStatus");
					backendServer.ServerId = _ctx.StringValue("DescribeBackendServers.Listeners["+ i +"].BackendServers["+ j +"].ServerId");

					listener_backendServers.Add(backendServer);
				}
				listener.BackendServers = listener_backendServers;

				describeBackendServersResponse_listeners.Add(listener);
			}
			describeBackendServersResponse.Listeners = describeBackendServersResponse_listeners;
        
			return describeBackendServersResponse;
        }
    }
}
